package cn.bonoon.kernel.web.components;

import cn.bonoon.kernel.descriptors.UIPropertyAccessor;
import cn.bonoon.kernel.web.annotations.components.AsTimeSpinner;
import cn.bonoon.kernel.web.html.UIPropertyBuilder;
import cn.bonoon.kernel.web.html.form.ComponentPropertyParser;

public class TimeSpinnerComponent extends UIComponent {
	private final AsTimeSpinner com;

	public TimeSpinnerComponent(ComponentPropertyParser property, UIPropertyAccessor accessor, AsTimeSpinner com) {
		super("buptimespinner", property, accessor);
		this.com = com;
	}
	
	@Override
	protected void initComponentAttribute(StringBuilder script, UIPropertyBuilder builder) {
		if (!Double.isNaN(com.max())){
			script.append(",max:").append(com.max());
		}
		if (!Double.isNaN(com.min())){
			script.append(",min:").append(com.min());
		}
		if (com.increment() > 0){
			script.append(",increment:").append(com.increment());
		}
		if (com.highlight() > 0){
			script.append(",highlight:").append(com.highlight());
		}
		if (com.showSeconds()){
			script.append(",withSecond:true"); // showSeconds
		}
	}
}
